package com.irdstudio.efp.esb.service.impl.hj;

import com.irdstudio.basic.framework.core.constant.EsbRetCodeStandard;
import com.irdstudio.efp.esb.common.client.resp.EsbRespRetInfBean;
import com.irdstudio.efp.esb.common.client.resp.EsbRespServiceBean;
import com.irdstudio.efp.esb.common.constant.dxm.DxmEnum;
import com.irdstudio.efp.esb.service.bo.req.hj.ReqAccountFundsFreezeBean;
import com.irdstudio.efp.esb.service.bo.req.hj.ReqCusOvdueBillBean;
import com.irdstudio.efp.esb.service.bo.resp.hj.RespAccountFundsFreezeBean;
import com.irdstudio.efp.esb.service.bo.resp.hj.RespCusOvdueBillBean;
import com.irdstudio.efp.esb.service.client.ESBClientFactory;
import com.irdstudio.efp.esb.service.client.impl.LhxESBBeanCreator;
import com.irdstudio.efp.esb.service.facade.hj.CusOvdueBillService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 * 互金客户逾期借据查询接口接口实现类
 *
 */
@Service("cusOvdueBillService")
public class CusOvdueBillServiceImpl implements CusOvdueBillService {

	@Override
	public RespCusOvdueBillBean cusOvdueBill(ReqCusOvdueBillBean reqCus) throws Exception {
		Logger logger = LoggerFactory.getLogger(BorrowingMoreServiceImpl.class);
		// 返回对象
		RespCusOvdueBillBean respCus = null;
		logger.info("调用互金客户逾期借据查询接口，全局流水号【{}】，客户号【{}】",reqCus.getGolSerno(),reqCus.getCustNo());
		try {
			// 1.调用ESB客户端服务
			EsbRespServiceBean esbRespServiceBean = ESBClientFactory
					.buildClient()
					.withBody(reqCus)
					.withTradeNo("40130018")
					.withScene("01")
					.withESBBeanFactory(LhxESBBeanCreator.getINSTANCE())
					.create()
					.sendAndReceive();
			EsbRespRetInfBean retInfArry = esbRespServiceBean.getSysHead().getRetInfArry().get(0);
			if (!EsbRetCodeStandard.SUCCESS.getValue().equals(retInfArry.getRetCd())) {
				throw new Exception("查询客户逾期状态失败，信息为" + retInfArry.getRetMsg());
			}
			return esbRespServiceBean.getBody(RespCusOvdueBillBean.class);
		} catch (Exception e) {
			logger.error("调用互金客户逾期借据查询接口！", e);
			throw e;
		}
	}

}
